package com.example.im.rxjava

import io.reactivex.ObservableTransformer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

object RxJavaHelper {
    /**
     * 切换线程操作
     *
     * @return Observable转换器
     */
    fun <T> observeOnMainThread(): ObservableTransformer<T, T> {
        return ObservableTransformer { upstream ->
            upstream.subscribeOn(Schedulers.io())//启动订阅线程
                .observeOn(AndroidSchedulers.mainThread())//切换至主线程
        }
    }
}
